<%@page import="org.apache.tomcat.jni.FileInfo"%>
<%@page import="java.util.ArrayList"%>
<%@page import="study.top.mydb.items.NboardItem"%>
<%@page import="study.top.mydb.Nboard"%>
<%@page import="study.top.jsp.PageHandler"%>
<%@page import="study.top.mydb.items.ReplyItem"%>
<%@page import="study.top.mydb.Reply"%>
<%@page import="study.top.common.DateTime"%>
<%@page import="study.top.mydb.items.BoardItem"%>
<%@page import="study.top.mydb.Board"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true" %>
<%@ include file = "dbcon.jsp"  %>

<%
db.connect();
	int seq = web.getInt("seq");
	

	if(seq<0) {
		web.goPage(null, "파라미터가 없습니다.");
		db.disconnect();
		return;
	}

	Nboard nboard = new Nboard();
	NboardItem item = nboard.selectNboard(seq);
	db.disconnect();

	if(item==null) {
		web.goPage(null, "게시물 데이터를 불러오는데 실패했습니다.");		
		return;
	}


%>
<!DOCTYPE html>
<html lang="ko">
	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"/>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<title>공지사항 보기</title>

		<!-- 모바일 웹 페이지 설정 -->
		<link rel="shortcut icon" href="assets/ico/favicon.png" />
		<link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png" />
		<link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png" />
		<link rel="apple-touch-icon-precomposed" sizes="114x114" href="assets/ico/apple-touch-icon-114-precomposed.png" />
		<link rel="apple-touch-icon-precomposed" sizes="144x144" href="assets/ico/apple-touch-icon-144-precomposed.png" />

		<!-- bootstrap -->
		<link rel="stylesheet" type="text/css" href="assets/css/bootstrap.min.css" />
		<link rel="stylesheet" type="text/css" href="assets/css/topCommon.css" />
		
		<!-- 나눔고딕 웹 폰트 적용 -->
		<link rel="stylesheet" type="text/css" href="assets/css/nanumfont.css" />
		<!-- 반응형 웹을 지원하지 않을 경우 -->
		<!-- <link rel="stylesheet" href="assets/css/non-responsive.css" /> -->

		<!-- IE8 이하 버전 지원 -->
		<!--[if lt IE 9]>
		<script type="text/javascript" src="assets/js/html5shiv.js"></script>
		<script type="text/javascript" src="assets/js/respond.min.js"></script>
		<![endif]-->

		<!-- IE10 반응형 웹 버그 보완 -->
		<!--[if gt IE 9]>
		<link rel="stylesheet" type="text/css" href="assets/css/ie10.css" />
		<script type="text/javascript" src="assets/js/ie10.js"></script>
		<![endif]-->
		
	</head>

	<body>
	<!-- .modal -->
		<div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			<!-- .modal-dialog -->
			<form class="modal-dialog" name="delete_form" method="post" action="nBoardDelete.jsp" role="form">
				<input type="hidden" name="seq" value="<%=seq%>" />
				<!-- .modal-content -->
				<div class="modal-content">
					<!-- 제목 -->
					<div class="modal-header">
						<!-- 닫기버튼 -->
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							&times;
						</button>
						<h4 class="modal-title" id="myModalLabel">게시물 삭제</h4>
					</div>
					<!-- 내용 -->
					<div class="modal-body">
						<h4>정말 게시물을 삭제하시겠습니까?</h4>
						
					</div>
					<!-- 하단 -->
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">
							취소
						</button>
						<button type="submit" class="btn top-btn-custom">
							삭제
						</button>
					</div>
				</div>
				<!-- /.modal-content -->
			</form>
			<!-- /.modal-dialog -->
		</div>
		<!-- /.modal -->
			<div class="container">
		
			<div class="page-header">
				<h3>공지사항</h3>
			</div>
	
			<form class="form-horizontal" role="form" action="nBoardUpdate.jsp" method="post">
				<input type="hidden" name="seq" value="<%=seq%>" />
				
				<fieldset>			
				
				
				<div class="table-responsive">
			<table class="table table-striped table-hover ">
				<thead>
					<tr>
						<th>
							<h4><%=item.getTitle()%></h4>
							<div class="pull-right">
								<%=DateTime.getInstance().getDateTimeString(item.getReg_date())%>
							</div>
						</th>
								
					</tr>
				</thead>
				
				
				<tbody>
					<tr class="text-center">
						
						<td class="text-left">
							<p>
								글쓴이 : 
								<a class="text-left" href=""><%=item.getMember_seq()%></a>
								
							</p>
						
						</td>
					
					</tr>
					
					
				</tbody>
			</table>
			<%=item.getContent() %>
		</div>
				
						
					
					<!-- 입력양식 -->
					<div class="form-group">
						<div class="col-md-12">

						</div>
					</div>
					<!--// 입력양식 -->
					
					<!-- 입력양식 -->
					<div class="form-group">
						<div class="col-md-12">
						
							<div class="col-md-12">
						
								<div class="pull-left">			
									<button type="submit" class="btn top-btn-custom ">수정</button>
									<a data-toggle="modal" href="#myModal"class="btn top-btn-custom">삭제</a>
									<a href="aMnBoardList.jsp" class="btn top-btn-custom">전체 공지사항보기</a>
								
								
								</div>
							</div>
						</div>
					</div>
					<!--// 입력양식 -->
					
					
					
				</fieldset>
			</form>
			
			<hr/>
			
		
			
					<!-- 결과를 출력하기 위한 영역 -->
					<div id="result"></div>
			
					<hr/>
			
		
		</div>
		
	
				<!-- Javascript -->
				<script src="assets/js/jquery.js"></script>
				<script src="assets/js/bootstrap.min.js"></script>
				<script src="assets/js/holder.js"></script>
				<script src="assets/js/lightbox-2.6.min.js"></script>
				<script src="assets/js/jquery.tmpl.min.js"></script>
				<script src="assets/js/jquery.xml2json.js"></script>
				<script type="text/javascript">
			$(function(){
							
					$.ajax({
						url: "ajax/reply.jsp",
						
						dataType: "xml",
						data:"board_seq="+seq,
						timeout: 30000,
						cache: false,
						success: function(req) {
							
							$(req).find("item").each(function(){
								
								var memberID = $(this).find("member_seq").text();
								var content = $(this).find("content").text();
								
								var span = $("<span>").addClass("label label-primary").html(memberID);
								var p = $("<p>").html("&nbsp;"+content);
								
								p.prepend(span);
								
								$("#result").append(p);
								
							});																			
						},
						error: function(xhr, status, error) {
							alert("status: "+status+" /error-code: "+xhr.status+""+error);

						}
					});
				});

		</script>
				
	</body>
</html>